<?php if(!defined('BASEPATH')) exit('No direct script access allowed');

function parse_bbcode($str = '') {


    $find = array(
        "'\[b\](.*?)\[/b\]'is",
        "'\[i\](.*?)\[/i\]'is",
        "'\[u\](.*?)\[/u\]'is",
         "'\[img\](.*?)\[/img\]'i",
        /*
        "'\[s\](.*?)\[/s\]'is",
       
        "'\[url\](.*?)\[/url\]'i",
        "'\[url=(.*?)\](.*?)\[/url\]'i",
        "'\[link\](.*?)\[/link\]'i",
        "'\[link=(.*?)\](.*?)\[/link\]'i"
         * 
         */
    );

    $replace = array(
        '<b>\1</b>',
        '<i>\1</i>',
        '<u>\1</u>',
        '<img src="\1" alt="" />',
        /*
        '<s>\1</s>',
        
        '<a href="\1">\1</a>',
        '<a href="\1">\2</a>',
        '<a href="\1">\1</a>',
        '<a href="\1">\2</a>'
         * 
         */
    );

    return preg_replace($find, $replace, $str);
}
